/**
 * 
 */
package com.gome.axwl.aoc.common.util;

import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.net.URI;
import java.util.List;


/**   
* http 请求   
* 项目名称：gome-pms-common   
* 类名称：HttpUtils   
* 类描述：   暂时使用 ,后期使用cloud服务调用远程接口
* 创建人：wyan   
* 创建时间：2018年2月1日 下午3:01:00   
* @version        
*/
public class HttpUtils {
	
    public static String sendMessage(String rmUserIp,Integer rmUserPort,String rmUserPath,List<NameValuePair> list,
			String encode){
       URI uri = null;
       String result = "";
       
    try {

        CloseableHttpClient endTime = HttpClients.createDefault();
        uri = (new URIBuilder()).setScheme("http")
        		.setHost(rmUserIp)
                .setPort(rmUserPort)
                .setPath(rmUserPath)
                .setParameters(list)
                .build();
        HttpGet httpget = new HttpGet(uri);
       // HttpPost httpPost = new HttpPost(uri);
       // httpPost.addHeader("Content-type","application/json;charset=utf-8");
        httpget.addHeader("Content-type","application/json;charset=utf-8");
        CloseableHttpResponse response = endTime.execute(httpget);
        HttpEntity entity = response.getEntity();
        result = EntityUtils.toString(entity);
        //System.out.println("sendMessage Util "+result);
        response.close();
        
    } catch (Throwable var12) {
    	var12.printStackTrace();
    }
    return result;
   }
    
//    public static void main(String[] args){
//    	List<NameValuePair> list = new ArrayList<>();
//    	list.add(new BasicNameValuePair("pageNum","1"));
//    	list.add(new BasicNameValuePair("pageSize","10"));
//    	String values = sendMessage(list,null);
//    }
}
